//
//  AppDelegate.m
//  30iMonitor
//
//  Created by Lv Kin on 12-11-25.
//  Copyright (c) 2012年 30iMonitor. All rights reserved.
//

#import "AppDelegate.h"
#import "OverviewViewController.h"
#import "WarningsViewController.h"
#import "MonitorDataViewController.h"
#import "BusinessMonitorViewController.h"
#import "SettingsViewController.h"

@interface AppDelegate (Private)

/*!
 @method
 @abstract Build user interface
 */
- (void)buildUserInterface;

@end

@implementation AppDelegate

- (void)dealloc
{
    [_window release];
    [_tabBarController release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    
    //Build UI
    [self buildUserInterface];
        
    return YES;
}

- (void)applicationWillTerminate:(UIApplication *)application {
}

#pragma mark - 
#pragma mark - Private methods

- (void)buildUserInterface {
    //Build root tabbar controller
    OverviewViewController *overviewViewController = [[OverviewViewController alloc] init];
    overviewViewController.title = NSLocalizedString(@"Overview panel", nil);
    overviewViewController.tabBarItem.image = [UIImage imageNamed:@"home_icon.png"];
    
    UINavigationController *overviewNavigationController = [[UINavigationController alloc] initWithRootViewController:overviewViewController];
    overviewNavigationController.navigationBar.barStyle = UIBarStyleBlack;
    [overviewViewController release];
    
    WarningsViewController *warningsViewController = [[WarningsViewController alloc] init];
    warningsViewController.title = NSLocalizedString(@"Current warnings", nil);
    warningsViewController.tabBarItem.image = [UIImage imageNamed:@"alarm_icon.png"];
    
    UINavigationController *warningsNavigationController = [[UINavigationController alloc] initWithRootViewController:warningsViewController];
    warningsNavigationController.navigationBar.barStyle = UIBarStyleBlack;
    [WarningsViewController release];
    
    MonitorDataViewController *monitorDataViewController = [[MonitorDataViewController alloc] init];
    monitorDataViewController.title = NSLocalizedString(@"Monitor data", nil);
    monitorDataViewController.tabBarItem.image = [UIImage imageNamed:@"monitordata_icon.png"];
    
    UINavigationController *monitorDataNavigationController = [[UINavigationController alloc] initWithRootViewController:monitorDataViewController];
    monitorDataNavigationController.navigationBar.barStyle = UIBarStyleBlack;
    [monitorDataViewController release];
    
    BusinessMonitorViewController *businessMonitorViewController = [[BusinessMonitorViewController alloc] init];
    businessMonitorViewController.title = NSLocalizedString(@"Business monitor", nil);
    businessMonitorViewController.tabBarItem.image = [UIImage imageNamed:@"bussymonitor_icon.png"];
    
    UINavigationController *businessMonitorNavigationController = [[UINavigationController alloc] initWithRootViewController:businessMonitorViewController];
    businessMonitorNavigationController.navigationBar.barStyle = UIBarStyleBlack;
    [businessMonitorViewController release];
    
    SettingsViewController *settingsViewController = [[SettingsViewController alloc] init];
    settingsViewController.title = NSLocalizedString(@"Settings", nil);
    settingsViewController.tabBarItem.image = [UIImage imageNamed:@"setting_icon.png"];
    
    UINavigationController *settingsNavigationController = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
    settingsNavigationController.navigationBar.barStyle = UIBarStyleBlack;
    [settingsViewController release];
    
    
    
    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:overviewNavigationController,warningsNavigationController,monitorDataNavigationController,businessMonitorNavigationController,settingsNavigationController, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    
    
    [overviewNavigationController release];
    [warningsNavigationController release];
    [monitorDataNavigationController release];
    [businessMonitorNavigationController release];
    [settingsNavigationController release];

}

@end
